import 'package:wheel_of_fortune/model/participate_model.dart';

class RaffleModel {
  String id;
  String raffleId;
  String raffleName;
  String raffleDescription;
  String startDate;
  String endDate;
  int requiredCopiesNumber;
  int participatedCopies;
  int price;
  String productName;
  List<String> productPictureUrls;
  String productDescription;
  bool virtualOfRaffleDue;
  int requiredVirtualCopiesNumber;
  String status;

  RaffleModel(
      {this.id,
      this.raffleId,
      this.raffleName,
      this.raffleDescription,
      this.startDate,
      this.endDate,
      this.requiredCopiesNumber,
      this.participatedCopies,
      this.price,
      this.productName,
      this.productPictureUrls,
      this.productDescription,
      this.virtualOfRaffleDue,
      this.requiredVirtualCopiesNumber,
      this.status});

  RaffleModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    raffleId = json['raffleId'];
    raffleName = json['raffleName'];
    raffleDescription = json['raffleDescription'];
    startDate = json['startDate'];
    endDate = json['endDate'];
    requiredCopiesNumber = json['requiredCopiesNumber'];
    participatedCopies = json['participatedCopies'];
    price = json['price'];
    productName = json['productName'];
    productPictureUrls = json['productPictureUrls'].cast<String>();
    productDescription = json['productDescription'];
    virtualOfRaffleDue = json['virtualOfRaffleDue'];
    requiredVirtualCopiesNumber = json['requiredVirtualCopiesNumber'];
    status = json['status'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['raffleId'] = this.raffleId;
    data['raffleName'] = this.raffleName;
    data['raffleDescription'] = this.raffleDescription;
    data['startDate'] = this.startDate;
    data['endDate'] = this.endDate;
    data['requiredCopiesNumber'] = this.requiredCopiesNumber;
    data['participatedCopies'] = this.participatedCopies;
    data['price'] = this.price;
    data['productName'] = this.productName;
    data['productPictureUrls'] = this.productPictureUrls;
    data['productDescription'] = this.productDescription;
    data['virtualOfRaffleDue'] = this.virtualOfRaffleDue;
    data['requiredVirtualCopiesNumber'] = this.requiredVirtualCopiesNumber;
    data['status'] = this.status;
    return data;
  }
}

class WinnerInformationModel {
  int userId;
  String username;
  String userPhoneNumber;
  String userRegion;
  String ticketNumber;

  WinnerInformationModel(
      {this.userId,
      this.username,
      this.userPhoneNumber,
      this.userRegion,
      this.ticketNumber});

  WinnerInformationModel.fromJson(Map<String, dynamic> json) {
    userId = json['userId'];
    username = json['username'];
    userPhoneNumber = json['userPhoneNumber'];
    userRegion = json['userRegion'];
    ticketNumber = json['ticketNumber'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['userId'] = this.userId;
    data['username'] = this.username;
    data['userPhoneNumber'] = this.userPhoneNumber;
    data['userRegion'] = this.userRegion;
    data['ticketNumber'] = this.ticketNumber;
    return data;
  }
}


class RaffleRecordModel {
  String id;
  String raffleId;
  String raffleName;
  String raffleDescription;
  String startDate;
  String endDate;
  int requiredCopiesNumber;
  int participatedCopies;
  int price;
  String productName;
  List<String> productPictureUrls;
  String status;
  List<ParticipateModel> participates;

  RaffleRecordModel(
      {this.id,
      this.raffleId,
      this.raffleName,
      this.raffleDescription,
      this.startDate,
      this.endDate,
      this.requiredCopiesNumber,
      this.participatedCopies,
      this.price,
      this.productName,
      this.productPictureUrls,
      this.status,
      this.participates});

  RaffleRecordModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    raffleId = json['raffleId'];
    raffleName = json['raffleName'];
    raffleDescription = json['raffleDescription'];
    startDate = json['startDate'];
    endDate = json['endDate'];
    requiredCopiesNumber = json['requiredCopiesNumber'];
    participatedCopies = json['participatedCopies'];
    price = json['price'];
    productName = json['productName'];
    productPictureUrls = json['productPictureUrls'].cast<String>();
    status = json['status'];
    if (json['participates'] != null) {
      participates = new List<ParticipateModel>();
      json['participates'].forEach((v) {
        participates.add(new ParticipateModel.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['raffleId'] = this.raffleId;
    data['raffleName'] = this.raffleName;
    data['raffleDescription'] = this.raffleDescription;
    data['startDate'] = this.startDate;
    data['endDate'] = this.endDate;
    data['requiredCopiesNumber'] = this.requiredCopiesNumber;
    data['participatedCopies'] = this.participatedCopies;
    data['price'] = this.price;
    data['productName'] = this.productName;
    data['productPictureUrls'] = this.productPictureUrls;
    data['status'] = this.status;
    if (this.participates != null) {
      data['participates'] = this.participates.map((v) => v.toJson()).toList();
    }
    return data;
  }
}